﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using frag_boardgame;
using System.Xml;
using System.Xml.Serialization;
using System.IO;
using System.Runtime;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Serialization.Formatters.Soap;
using DataBase;

namespace DBUploader
{
    
    class Program
    {
        static void Main(string[] args)
        {
            
            Board board = new Board(15,25);
            
            board.GetSquare(3, 2).AddWall(SquareWalls.Left);
            board.GetSquare(4, 2).AddWall(SquareWalls.Left);
            board.GetSquare(5, 2).AddWall(SquareWalls.Left);
            board.GetSquare(6, 2).AddWall(SquareWalls.Left);
            board.GetSquare(7, 2).AddWall(SquareWalls.Left);
            board.GetSquare(3, 2).AddWall(SquareWalls.Down);
            board.GetSquare(3, 3).AddWall(SquareWalls.Down);
            board.GetSquare(3, 4).AddWall(SquareWalls.Down);
            board.GetSquare(3, 4).AddWall(SquareWalls.Right);
            board.GetSquare(4, 2).AddWall(SquareWalls.Up);
            board.GetSquare(4, 3).AddWall(SquareWalls.Up);

            board.GetSquare(4, 8).AddWall(SquareWalls.Left);
            board.GetSquare(5, 8).AddWall(SquareWalls.Left);
            board.GetSquare(6, 8).AddWall(SquareWalls.Left);
            board.GetSquare(7, 8).AddWall(SquareWalls.Left);
            board.GetSquare(8, 8).AddWall(SquareWalls.Left);
            board.GetSquare(4, 10).AddWall(SquareWalls.Right);
            board.GetSquare(5, 10).AddWall(SquareWalls.Right);
            board.GetSquare(6, 10).AddWall(SquareWalls.Left);
            board.GetSquare(7, 10).AddWall(SquareWalls.Right);
            board.GetSquare(8, 10).AddWall(SquareWalls.Right);
            board.GetSquare(3, 8).AddWall(SquareWalls.Up);
            board.GetSquare(3, 9).AddWall(SquareWalls.Up);
            board.GetSquare(3, 10).AddWall(SquareWalls.Up);
            board.GetSquare(6, 10).AddWall(SquareWalls.Up);
            board.GetSquare(6, 10).AddWall(SquareWalls.Down);

            board.GetSquare(5, 14).AddWall(SquareWalls.Left);
            board.GetSquare(6, 14).AddWall(SquareWalls.Left);
            board.GetSquare(7, 14).AddWall(SquareWalls.Left);
            board.GetSquare(8, 14).AddWall(SquareWalls.Left);
            board.GetSquare(9, 14).AddWall(SquareWalls.Left);
            board.GetSquare(5, 17).AddWall(SquareWalls.Left);
            board.GetSquare(6, 17).AddWall(SquareWalls.Left);
            board.GetSquare(7, 17).AddWall(SquareWalls.Left);
            board.GetSquare(8, 17).AddWall(SquareWalls.Left);
            board.GetSquare(9, 17).AddWall(SquareWalls.Left);
            board.GetSquare(5, 14).AddWall(SquareWalls.Down);
            board.GetSquare(5, 15).AddWall(SquareWalls.Down);
            board.GetSquare(5, 16).AddWall(SquareWalls.Down);
            board.GetSquare(7, 15).AddWall(SquareWalls.Down);

            board.GetSquare(6, 20).AddWall(SquareWalls.Left);
            board.GetSquare(7, 20).AddWall(SquareWalls.Left);
            board.GetSquare(8, 20).AddWall(SquareWalls.Left);
            board.GetSquare(9, 20).AddWall(SquareWalls.Left);
            board.GetSquare(10, 20).AddWall(SquareWalls.Left);
            board.GetSquare(8, 23).AddWall(SquareWalls.Left);
            board.GetSquare(9, 23).AddWall(SquareWalls.Left);
            board.GetSquare(10, 23).AddWall(SquareWalls.Left);
            board.GetSquare(6, 20).AddWall(SquareWalls.Down);
            board.GetSquare(6, 21).AddWall(SquareWalls.Down);
            board.GetSquare(6, 22).AddWall(SquareWalls.Down);
            board.GetSquare(10, 20).AddWall(SquareWalls.Up);
            board.GetSquare(10, 21).AddWall(SquareWalls.Up);
            board.GetSquare(10, 22).AddWall(SquareWalls.Up);
            board.GetSquare(8, 22).AddWall(SquareWalls.Down);


            DataContractSerializer dcs = new DataContractSerializer(typeof(Board));

            MemoryStream ms = new MemoryStream();
            StreamReader sr = new StreamReader(ms);
            StreamWriter sw = new StreamWriter(ms);

            dcs.WriteObject(ms, board);

            DBAdapter dba = new DBAdapter();
            board = new Board(2, 2);
            dba.addBoard("SMALL", board);

            board = dba.getBoard("SMALL");

            Console.ReadKey();
        }
    }
}
